home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Examples / CExamples / Instructions < prev    next >
Encoding:
Text File  |  1998-12-03  |  10.2 KB  |  299 lines  |  [TEXT/MPS ]

  1. Instructions - The C Examples
  2.  
  3. Copyright Apple Computer, Inc.  © 1987-1995
  4. All rights reserved.
  5.  
  6.  
  7. About the Examples
  8.  
  9.     Eight sample C programs are included with ETO: an application,
  10.     a tool, a desk accessory, and a program that demonstrates the
  11.     use of performance tools:
  12.     
  13.         Sample     - a simple MultiFinder-Aware Sample application
  14.         TESample   - a simple MultiFinder-Aware TextEdit application 
  15.         SillyBalls - a simple Color Quickdraw sample application
  16.                             (Requires Color Quickdraw)
  17.         TubeTest   - a simple Color Quickdraw & Palette Manager 
  18.                             Sample application
  19.                             (Requires Color Quickdraw)
  20.         Count      - an MPW tool
  21.         Memory     - a sample desk accessory
  22.         EditCdev   - a sample Control Panel Device with a TextEdit item 
  23.         TestPerf   - a performance demonstration tool
  24.  
  25.     The source files for each of these examples are in the
  26.     "Examples:CExamples:" folder.  A single makefile is provided
  27.     which contains the commands necessary to build each of the
  28.     targets.
  29.     
  30.  
  31. Building the Examples
  32.  
  33.     You can easily build each of the sample programs using the Directory
  34.     and Build menus.  (See "Building & Managing Programs In MPW".)
  35.     
  36.     Set the default directory to "CExamples:"
  37.  
  38.         The simplest way to do this is to select from the Directory menu
  39.         the menu item that ends in "CExamples:".  You can also set the
  40.         default directory by using the Directory and SetDirectory commands.
  41.         
  42.  
  43.     Build the program
  44.     
  45.         To build a sample application, type "make <sample name>".
  46.         You may redirect the output of make to a temporary file,
  47.         using the redirection character ">"; or, you may allow make 
  48.         to write to the current window.
  49.         
  50.         For example,
  51.         
  52.           make Count > Count.makeout
  53.           
  54.         Will generate the build commands for the Count sample,
  55.         and redirect output to a file (which is created) named
  56.         Count.makeout.  You may then execute Count.makeout.    
  57.  
  58. Sample - A Simple MultiFinder-Aware Sample Application
  59.  
  60.     Sample is an example application that demonstrates how to initialize
  61.     the commonly used toolbox managers, operate successfully under 
  62.     MultiFinder, handle desk accessories and create, grow, and zoom windows.
  63.     The source for Sample (or TESample below) provides an excellent
  64.     framework for basing new applications.
  65.      The source is contained in the files Sample.c and Sample.h, resource
  66.     descriptions are contained in the files Sample.h and Sample.r.
  67.     The make dependency file is named Sample.make.
  68.  
  69.    To build Sample, simply select the lines below and press Enter.
  70.  
  71.         make Sample > Sample.makeout
  72.         Sample.makeout
  73.         delete Sample.makeout
  74.  
  75.    To execute Sample, select the line below and press Enter.
  76.  
  77.         Sample
  78.  
  79.  
  80.  
  81. TESample - A Simple MultiFinder-Aware TextEdit Application
  82.  
  83.     TESample is an example application that demonstrates how to initialize
  84.     the commonly used toolbox managers, operate successfully under 
  85.     MultiFinder, handle desk accessories and create, grow, and zoom windows.
  86.     The fundamental TextEdit toolbox calls and TextEdit autoscroll are 
  87.     demonstrated. TESample also shows how to create and maintain scrollbar
  88.     controls.
  89.     The source for TESample (or Sample above) provides an excellent
  90.     framework for basing new applications.
  91.     The source is contained in the files TESample.c, TESampleGlue.a and
  92.     TESample.h, resource descriptions are contained in the files
  93.     TESample.h and TESample.r. The make dependency file is named
  94.     TESample.make.
  95.     
  96.    To build TESample, simply select the lines below and press Enter.
  97.  
  98.         make TESample > TESample.makeout
  99.         TESample.makeout
  100.         delete TESample.makeout
  101.  
  102.    To execute TESample, select the line below and press Enter.
  103.  
  104.         TESample
  105.  
  106.  
  107.  
  108. SillyBalls - A Simple Color Quickdraw Sample Application
  109.  
  110.     (Requires Color Quickdraw, e.g. MacII)
  111.  
  112.     SillyBalls is a very simple sample program that demonstrates 
  113.     how to use Color QuickDraw.  It is about two pages of code, and 
  114.     does nothing more than open a color window and draw randomly 
  115.     colored ovals in the window.
  116.     The purpose is to show how to get some initial results with Color 
  117.     QuickDraw. It is a complete program and is very short to be as 
  118.     clear as possible.
  119.     The source is contained in the file SillyBalls.c.
  120.  
  121.    To build SillyBalls, simply select the lines below and press Enter.
  122.  
  123.         make SillyBalls > SillyBalls.makeout
  124.         SillyBalls.makeout
  125.         delete SillyBalls.makeout
  126.         
  127.    To execute SillyBalls, select the line below and press Enter.
  128.  
  129.         SillyBalls
  130.  
  131.  
  132.  
  133. TubeTest - A Simple Color Quickdraw & Palette Manager Sample Application
  134.  
  135.     (Requires Color Quickdraw, e.g. MacII)
  136.  
  137.     TubeTest is a simple demonstration of how to use 
  138.     the Palette Manager in a color program.  It has a special color 
  139.     palette that is associated with the main window.  The colors are
  140.     animated using the Palette Manager to give a flowing tube effect.
  141.     The program is very simple, and the Palette Manager and drawing 
  142.     parts are put in separate subroutines to make it easier to figure 
  143.     out what is happening.
  144.     The source is contained in the files TubeTest.c and TubeTest.r
  145.  
  146.    To build TubeTest, simply select the lines below and press Enter.
  147.  
  148.         make TubeTest > TubeTest.makeout
  149.         TubeTest.makeout
  150.         delete TubeTest.makeout
  151.         
  152.    To execute TubeTest, select the line below and press Enter.
  153.  
  154.         TubeTest
  155.  
  156.  
  157.  
  158. Count - A Sample MPW Tool
  159.  
  160.     Count, a tool that runs in the MPW environment, counts characters and
  161.     lines in files.  A version of Count is included with MPW, and is
  162.     documented in the MPW Command Reference.  The source for Count is in
  163.     the files Count.c, FStubs.c, and Count.r.  MakeFile contains the
  164.     commands for building Count.
  165.  
  166.    To build Count, simply select the lines below and press Enter.
  167.  
  168.         make Count > Count.makeout
  169.         Count.makeout
  170.         delete Count.makeout
  171.         
  172.    To test Count, try counting the characters in file Count.c.
  173.  
  174.         Count -c Count.c ∑∑ "{Worksheet}"
  175.  
  176.  
  177.  
  178. Memory - A Sample Desk Accessory
  179.  
  180.  
  181.    Memory is a sample desk accessory written in C.  It displays the memory
  182.     available in the application and system heaps, and on the boot disk.
  183.     MakeFile contains the commands for building Memory.
  184.  
  185.    To build Memory, simply select the line below and press Enter.
  186.  
  187.         make Memory > Memory.makeout
  188.         Memory.makeout
  189.         delete Memory.makeout
  190.  
  191.    To launch the Memory DA, switch to the Finder and double-click
  192.    on the Memory icon.
  193.  
  194.  
  195.  
  196. EditCdev - A Sample Control Panel Device in C
  197.  
  198.     EditCdev demonstrates how to implement a editText item
  199.     in a Control Panel Device.  It utilizes the new undo, cut, copy,
  200.     paste, and delete messages that are sent to cdevs in
  201.     response to user menu selections.
  202.  
  203.    To build EditCdev, simply select the line below and press Enter.
  204.  
  205.         make EditCdev > EditCdev.makeout
  206.         EditCdev.makeout
  207.         delete EditCdev.makeout
  208.         
  209.     To execute EditCdev, after building it, simply select the Control
  210.     Panel from the Apple menu, and open the EditCdev icon in the list
  211.     of Control Panels.
  212.     
  213.  
  214.  
  215. TestPerf - An example of Using Performance Tools in C
  216.  
  217.     TestPerf is an MPW tool that demonstrates the use of the performance
  218.     measurement tools.  MakeFile contains the commands for building TestPerf.
  219.     Several of the latest PowerPC machines will not have ROM maps supplied.
  220.     Do not build TestPerf on such a machine.
  221.  
  222.    To build TestPerf, simply select the line below and press Enter.
  223.  
  224.         make TestPerf > TestPerf.makeout
  225.         TestPerf.makeout
  226.         delete TestPerf.makeout
  227.         
  228.     To execute TestPerf, select and execute the following command. (This
  229.     test will run about 15 to 60 seconds, depending upon the machine, with
  230.     only internal computations being performed):
  231.     
  232.         TestPerf
  233.  
  234.     TestPerf's raw performance data is written to the file Perform.out.
  235.     In this sample use of the performance measurement tools, the ROM was
  236.     measured.  So the ROM link map file needs to be combined with the program
  237.     link map file.  Because there are many different ROM maps, the build
  238.     process for TestPerf automatically appends the appropriate ROM map
  239.     for the current machine to the link  map file.  If you wish to do
  240.     this manually (for the cases where the program will be executed on
  241.     a machine other than the one used to build the program), you can
  242.     use a command similar to one of these:
  243.     
  244.  
  245.     # For Macintosh IIfx:
  246.         Catenate "{MPW}ROM Maps:MacIIfxROM.map" >> TestPerf.map
  247.         
  248.     # For Macintosh Quadra 950:
  249.         Catenate "{MPW}ROM Maps:MacQuadra950ROM.map" >> TestPerf.map
  250.         
  251.     # For Macintosh Quadra 840AV:
  252.         Catenate "{MPW}ROM Maps:MacQuadra840AVROM.map" >> TestPerf.map
  253.         
  254.     And so on…
  255.  
  256.     PerformReport is an MPW Tool that combines the output of the performance
  257.     tools with the link map file and produces a list of procedures, sorted by
  258.     estimated percent of time spent in each procedure.  To run PerformReport
  259.     execute the following command:
  260.  
  261.         PerformReport -l TestPerf.map -m Perform.Out > Report.Out
  262.  
  263.     The output of PerformReport is written to the file Report.Out.  To examine
  264.     this output, execute the following command:
  265.     
  266.         Open Report.Out
  267.  
  268.  
  269. Writing Your Own Programs
  270.  
  271.     After building (and perhaps modifying) the sample programs, you will
  272.     undoubtedly want to write a program of your own.  Use the New… item in
  273.     the File menu, to create the source files.  Remember that C language
  274.     source filenames should end in .c.
  275.     
  276.     Create Build Commands…  -  The Create Build Commands… item in the 
  277.     Build menu runs a script that creates a makefile containing the
  278.     commands for building programs written in C, Assembly Language, Pascal, 
  279.     and/or Rez.  Selecting Create Build Commands… displays a dialog box that 
  280.     allows you to enter information about your program.  Type the program's
  281.     name, select its source files by clicking the Files… button, and click
  282.     one of the radio buttons to indicate your choice of an application, tool,
  283.     or desk accessory.  
  284.     
  285.     Create Build Commands… puts the makefile for your program in the file
  286.     <program>.make.  Now you can use the Build menu to build and rebuild
  287.     your program, just as with the examples.
  288.     
  289.     Larger Programs  -  If you add source files as your program grows,
  290.     use Create Build Commands… again to add the new source files to the build
  291.     instructions.  If you out-grow the capabilities of the simple Create
  292.     Build Commands… script (perhaps by using tools other than Asm, C, Pascal,
  293.     Rez, and Link in your builds) you can modify the makefile yourself.
  294.     
  295.     Modifying the Directory and Build Menus  -  The Directory and Build
  296.     menus are both implemented using scripts written in the MPW Shell
  297.     command language.  This has the big advantage that you can modify
  298.     or customize them to match the way you work.
  299.